cmake_minimum_required(VERSION 3.10)

project(YamlCppExample)

set(yaml-cpp_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/yaml-080/_install_x86_64/lib/cmake/yaml-cpp")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR:${CMAKE_CURRENT_SOURCE_DIR}")
# find_package(yaml-cpp REQUIRED)
find_package(yaml-cpp)
if(yaml-cpp_FOUND)
    message(STATUS "yaml-cpp 版本       : ${yaml-cpp_VERSION}")
    message(STATUS "yaml-cpp 包含目录   : ${YAML_CPP_INCLUDE_DIR}")
    message(STATUS "yaml-cpp 库路径     : ${YAML_CPP_LIBRARY_DIR}")
    message(STATUS "yaml-cpp 库文件     : ${YAML_CPP_LIBRARIES}")
else()
    message(FATAL_ERROR "未找到yaml-cpp库，请检查yaml-cpp是否正确安装或CMAKE_PREFIX_PATH是否设置正确")
endif()

add_executable(YamlCppExample main_yaml.cpp)

# 链接时依赖：确保编译后的可执行文件能找到yaml-cpp库的函数实现
# 传递性依赖：自动包含yaml-cpp库所需的其他依赖项
# 构建顺序：CMake会确保先编译yaml-cpp库，再链接到yaml_example目标
target_link_libraries(YamlCppExample yaml-cpp::yaml-cpp)